package pkg

import (
	"fmt"
	"time"
)

func a() {
	//两个线程交替打印 1 a 2 b 3 c

	chInt := make(chan int)
	defer close(chInt)
	chStr := make(chan int)
	defer close(chStr)

	go func() {
		for i := 1; i <= 26; i++ {
			<-chInt
			fmt.Printf("输出数字 %d\n", i)
			chStr <- i
		}
	}()
	go func() {
		for i := 0; i <= 26; i++ {
			<-chStr
			fmt.Printf("输出数字 %c\n", 'a'+i)
			chInt <- i
		}
	}()
	//启动执行
	chInt <- 1

	time.Sleep(1 * time.Second)
	return
}
